package com.ericsson.enap.modules.ebmLog.task;

import com.ericsson.common.util.LogFileName;
import com.ericsson.common.util.LoggerUtils;
import com.ericsson.common.util.SpringUtils;
import com.ericsson.enap.modules.ebmLog.utils.EbmLogUtil;
import com.ericsson.enap.modules.ebmLog.service.EbmEventService;
import org.slf4j.Logger;

import java.util.concurrent.CountDownLatch;

/**
 * @description: ebmLog解析和最后的入库任务
 * @author: wangjingshi
 * @create: 2021-04-21 10:39
 */
public class EbmAnalysisAndInsertTask implements Runnable{

    private Logger log = LoggerUtils.Logger(LogFileName.EbmLogJob);

    private String localPath;
    private String dateTime;
    private String netid;
    private String event_type;
    private String event_name;
    private CountDownLatch inner_latch;
    private EbmEventService ebmEventService;

    public EbmAnalysisAndInsertTask(String localPath, String dateTime, String netid, String event_type, String event_name, CountDownLatch inner_latch) {
        this.localPath = localPath;
        this.dateTime = dateTime;
        this.netid = netid;
        this.event_type = event_type;
        this.inner_latch = inner_latch;
        this.event_name = event_name;
        this.ebmEventService = SpringUtils.getBean("ebm" + EbmLogUtil.captureName(event_name) + "ServiceImpl");
    }

    @Override
    public void run() {
        ebmEventService.executeEvent(localPath,dateTime,netid,event_type,event_name);
        inner_latch.countDown();
        log.info(netid+" ==== "+event_type+" ==== do(Rject,abort,ignore) AnalysisAndInsertTask");
    }
}
